home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / e_os300b / ex_64k / exampl13.asm next >
Encoding:
Assembly Source File  |  1996-11-21  |  4.5 KB  |  128 lines

  1. ;╔══════════════════════════════════════════════════════════════════════════╗
  2. ;║                                                                          ║
  3. ;║ This example show how to display two pictures (256 colors!) on the       ║
  4. ;║                                                                          ║
  5. ;║ screen                                                                   ║
  6. ;║                                                                          ║
  7. ;║ Tabs : 13 21 29 37                                                       ║
  8. ;║                                                                          ║
  9. ;╚══════════════════════════════════════════════════════════════════════════╝
  10.  
  11. Locals
  12. .386
  13. CODE32 SEGMENT PUBLIC PARA 'CODE' USE32
  14. ASSUME  CS:CODE32,DS:CODE32,ES:CODE32
  15.  
  16. INCLUDE ..\RESOURCE\EOS.INC
  17.  
  18. Offset_pic_1 = 640*80
  19. Offset_pic_2 = 640*80
  20.  
  21. File_Pic1   db '..\data\test640.dlz',0
  22. File_Pic2   db '..\data\eclipse.dlz',0
  23.  
  24. Addr_Pic    dd 0
  25. Adrs_Sel    dw ?
  26.  
  27. Palette     label word
  28.             dw 256 dup (?)
  29.  
  30. Sel_Txt     db '    ■ Out of selector !',13,10,36
  31. Vesa_Txt    db '    ■ Mode 640x480x64k not supported or VESA not found !',13,10
  32.             db '      To install a vesa driver, refer to your video card documentation.',13,10,36
  33.  
  34. Start32:
  35.             mov ax,Mode640x480x64k          ; Init SVGA Mode
  36.             call Init_Vesa                  ;
  37.             jnc NoError_Vesa                ;
  38.             mov edx,offset Vesa_Txt         ;
  39.             mov ah,Exit_Error               ;
  40.             Int_EOS                         ;
  41. NoError_Vesa:
  42.  
  43.             call Init_Vesa_Bank             ; Turn On the Automatic Bank Switching
  44.             mov [adrs_sel],bx               ;
  45.             jnc NoError_Sel                 ;
  46.             mov edx,offset Sel_Txt          ;
  47.             mov ah,Exit_Error               ;
  48.             Int_EOS                         ;
  49. NoError_Sel:
  50.  
  51.             mov ah,Load_Internal_File       ; Load the file
  52.             mov edx,O File_Pic1             ;
  53.             Int_EOS                         ;
  54.             mov [Addr_Pic],eax              ;
  55.  
  56.             mov esi,[Addr_Pic]              ; Convert palette (256 to 64k)
  57.             add esi,10                      ;
  58.             lea edi,Palette                 ;
  59.             call Convert_Palette_to_64k     ;
  60.  
  61.             xor edi,edi                     ; Display picture
  62.             add esi,offset_pic_1            ;
  63.             mov ecx,640*240                 ;
  64.             call display_64k                ;
  65.  
  66.             push edi                        ; Save the screen position
  67.  
  68.             mov ah,DeAllocate_Memory        ; UnLoad the last file
  69.             Int_EOS                         ;
  70.  
  71.             mov ah,Load_Internal_File       ; Load the file
  72.             mov edx,O File_Pic2             ;
  73.             Int_EOS                         ;
  74.             mov [Addr_Pic],eax              ;
  75.  
  76.             mov esi,[Addr_Pic]              ; Convert palette (256 to 64k)
  77.             add esi,10                      ;
  78.             lea edi,Palette                 ;
  79.             call Convert_Palette_to_64k     ;
  80.  
  81.             pop edi                         ; Display picture
  82.             add esi,offset_pic_2            ;
  83.             mov ecx,640*240                 ;
  84.             call display_64k                ;
  85.  
  86.             mov ah,DeAllocate_Memory        ; UnLoad the last file
  87.             Int_EOS                         ;
  88.  
  89.             xor ah,ah                       ; Wait a key
  90.             DosInt 16h
  91.  
  92.             call Close_Vesa_Bank            ; Turn Off the Automatic Bank Switching
  93.  
  94.             mov ax,4c00h                    ; Exit with Error Code 0
  95.             int 21h                         ; and Automaticly restore video Mode !!!
  96.  
  97. Convert_Palette_to_64k:                     ; Convert palette (256 to 64k)
  98.             mov ebp,256
  99. @@convert:
  100.             movzx eax,B [esi+0]
  101.             movzx ebx,B [esi+1]
  102.             movzx ecx,B [esi+2]
  103.             add esi,3
  104.             shr eax,1
  105.             shl eax,11
  106.             shl ebx,5
  107.             shr ecx,1
  108.             or  eax,ebx
  109.             or  eax,ecx
  110.             stosw
  111.             dec ebp
  112.             jnz @@convert
  113.             ret
  114.  
  115. Display_64k:
  116.             push es                         ; Display 64k picture
  117.             mov es,[adrs_sel]
  118. @@dsp:      xor eax,eax
  119.             lodsb
  120.             mov ax,W [Palette+eax*2]
  121.             stosw
  122.             loop @@dsp
  123.             pop es
  124.             ret
  125.  
  126.             CODE32 ENDS
  127.  
  128.             END